package com.hisan.freeride.home.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.hisan.freeride.R;
import com.hisan.freeride.common.base.BaseActivity;
import com.hisan.freeride.common.utils.CollectionUtils;
import com.hisan.freeride.common.utils.JSObject;
import com.hisan.freeride.common.view.ItemWebView;
import com.hisan.freeride.databinding.CommunityBinding;


/**
 * 通用广告页面
 * Created by Administrator on 2017/4/1.
 */

public class RotationActivity extends BaseActivity<CommunityBinding> {

    @Override
    protected int getLayoutId() {
        return R.layout.community;
    }

    @Override
    protected void initView() {
        String url=getIntent().getStringExtra("url");
        if (!CollectionUtils.isNullOrEmpty(url)){
            mBinding.itemWeb.setDrawable(this);
            mBinding.itemWeb.load(url,mBinding.titlename);
        }else {
            String html="file:///android_asset/404.html";
            mBinding.itemWeb.SetHtml(html);
        }
      ;
    }

    @Override
    protected void initEvent() {
    mBinding.topBack.setOnClickListener(v -> finishActivity(true));
    }

    @Override
    protected void loadData(boolean isRefresh) {
        JSObject jsObject = new JSObject(this);
        mBinding.itemWeb.addJavascriptInterface(jsObject,"android");
    }


    /**
     * 方法描述：跳转至本Activity
     *  @param activity     发起跳转的Activity
     */
    public static void skip(Activity activity, String html) {
        Intent intent = new Intent(activity, RotationActivity.class);
        intent.putExtra("url", html);
        activity.startActivity(intent);
    }
}
